<!--
 * @Author: summer12138 1343364145@qq.com
 * @Date: 2023-05-20 19:33:34
 * @LastEditors: summer12138 1343364145@qq.com
 * @LastEditTime: 2023-05-20 19:53:18
 * @FilePath: \Vue核心技术与实战 - 作业\作业day02\逛水果店.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!--
 * @Author: summer12138 1343364145@qq.com
 * @Date: 2023-05-20 19:33:34
 * @LastEditors: summer12138 1343364145@qq.com
 * @LastEditTime: 2023-05-20 19:51:42
 * @FilePath: \Vue核心技术与实战 - 作业\作业day02\逛水果店.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    table{
      margin: 100px auto;
      outline:solid 1px gray;
      text-align: center;
    }
    tr{
      outline: solid 1px gray;
    }
  </style>
</head>

<body>
  <div id="app">
    <table>
      <tr>
        <th>
          苹果10元/斤,折扣< 8折>
        </th>
      </tr>
      <tr>
        <td>请输入要买的斤数:<input type="text" v-model.number="num"></td>
      </tr>
      <tr>
        <td><button>结账买单</button></td>
      </tr>
      <tr>
        <td>结账单,总价{{total}}元,折扣价{{count}}元,省了{{other}}元</td>
      </tr>
    </table>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script>
    const vm = new Vue({
      el:'#app',
      data:{
        num:'',
      },
      methods: {
        
      },
      computed: {
        total(){
          return this.num*10
        },
        count(){
          return this.total*0.8
        },
        other(){
          return this.total-this.count
        }
      },
    })
  </script>
</body>

</html>